import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { maintenanceRecordVO, maintenanceRecordForm, maintenanceRecordQuery } from '@/api/maintenance/maintenance-record/types';

/**
 * 查询维保记录列表
 * @param query
 * @returns {*}
 */

export const listmaintenanceRecord = (query?: maintenanceRecordQuery): AxiosPromise<maintenanceRecordVO[]> => {
  return request({
    url: '/maintenance/maintenance-record/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询维保记录详细
 * @param equipmentMaintenanceRecordId
 */
export const getmaintenanceRecord = (equipmentMaintenanceRecordId: string | number): AxiosPromise<maintenanceRecordVO> => {
  return request({
    url: '/maintenance/maintenance-record/' + equipmentMaintenanceRecordId,
    method: 'get'
  });
};

/**
 * 新增维保记录
 * @param data
 */
export const addmaintenanceRecord = (data: maintenanceRecordForm) => {
  return request({
    url: '/maintenance/maintenance-record',
    method: 'post',
    data: data
  });
};

/**
 * 修改维保记录
 * @param data
 */
export const updatemaintenanceRecord = (data: maintenanceRecordForm) => {
  return request({
    url: '/maintenance/maintenance-record',
    method: 'put',
    data: data
  });
};

/**
 * 删除维保记录
 * @param equipmentMaintenanceRecordId
 */
export const delmaintenanceRecord = (equipmentMaintenanceRecordId: string | number | Array<string | number>) => {
  return request({
    url: '/maintenance/maintenance-record/' + equipmentMaintenanceRecordId,
    method: 'delete'
  });
};
